﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class LevelBLO
    {
        private LevelDAO _levelDao = new LevelDAO();

        /// <summary>
        /// get list of formats
        /// </summary>
        /// <returns>List of formats</returns>
        /// <author>hungph</author>
        public List<Level> LoadLevels()
        {
            var listFormat = _levelDao.LoadLevels();
            return listFormat;
        }

        /// <summary>
        /// get a format by formatID
        /// </summary>
        /// <returns>Format</returns>
        /// <author>hungph</author>
        public Level LoadLevelById(int id)
        {
            var level = _levelDao.LoadLevelsById(id);
            return level;
        }

        /// <summary>
        /// create a new level
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool CreateLevel(Level level)
        {
            var result = _levelDao.Add(level);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// edit level 
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool EditLevel(Level level)
        {
            var result = _levelDao.Edit(level);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// delete level
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool DeleteLevel(Level level)
        {
            var result = _levelDao.Delete(level);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Check if level is existed or not
        /// </summary>
        /// <param name="lev"></param>
        /// <returns>true || false</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public bool CheckIsExisted(Level lev)
        {
            return _levelDao.CheckIsExisted(lev);
        }

        public Level GetLevelById(int? id)
        {
            var level = _levelDao.GetLevelById(id);
            return level;
        }
    }
}